<?php
/**
 * ManiaLive - TrackMania dedicated server manager in PHP
 * 
 * @copyright   Copyright (c) 2009-2011 NADEO (http://www.nadeo.com)
 * @license     http://www.gnu.org/licenses/lgpl.html LGPL License 3
 * @version     $Revision: 181 $:
 * @author      $Author: floschnell $:
 * @date        $Date: 2011-02-11 17:25:13 +0000 (Fri, 11 Feb 2011) $:
 */

namespace ManiaLive\Utilities;

use ManiaLive\DedicatedApi\Structures\Player;

use ManiaLive\Config\Loader;

abstract class Console
{
	public static function println($string)
	{
		Logger::getLog('Runtime')->write($string.APP_NL);
		echo $string.APP_NL;
	}
	
	public static function print_rln($string)
	{
		$line = print_r($string, true);
		Logger::getLog('Runtime')->write($line.APP_NL);
		echo $line.APP_NL;
	}
	
	public static function getDatestamp()
	{
		return date("H:i:s");
	}
	
	public static function printlnFormatted($string)
	{
		$line = '[' . self::getDatestamp() . '] ' . $string;
		self::println($line);
	}
	
	public static function printDebug($string)
	{
		if (APP_DEBUG)
		{
			$line = '[' . self::getDatestamp() . '|Debug] ' . $string;
			self::println($line);
		}
	}
	
	public static function printPlayerBest(Player $player)
	{
		$str = array();
		$str[] = '[Time by ' . $player->login . ' : ' . $player->bestTime . ']';
		foreach ($player->bestCheckpoints as $i => $time)
		{
			$str[] = '  [Checkpoint #' . $i . ': ' . $time . ']';
		}
		Console::println(implode(APP_NL, $str));
	}
	
	public static function printPlayerScore(Player $player)
	{
		$str = array();
		$str[] = '[Score by ' . $player->login . ' : ' . $player->score . ']';
		foreach ($player->bestCheckpoints as $i => $score)
		{
			$str[] = '  [Checkpoint #' . $i . ': ' . $score . ']';
		}
		Console::println(implode(APP_NL, $str));
	}
}

?>